package com.example.myapplication8;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void buttonOk(View view) throws Exception {
        EditText id=findViewById(R.id.id);
        EditText text=findViewById(R.id.text);
        EditText A=findViewById(R.id.A);
        EditText B=findViewById(R.id.B);
        EditText C=findViewById(R.id.C);
        EditText D=findViewById(R.id.D);
        String sid=id.getText().toString(),stext=text.getText().toString(),sa=A.getText().toString(),sb=B.getText().toString(),sc=C.getText().toString(),sd=D.getText().toString();
        String filename="question.txt";
        FileOutputStream fos=openFileOutput(filename, Context.MODE_APPEND);
        String res=sid+" "+stext+" "+sa+" "+sb+" "+sc+" "+sd+" ";
        fos.write(res.getBytes());
        fos.flush();
        fos.close();
        Toast.makeText(this, "插入成功", Toast.LENGTH_SHORT).show();
    }
    public void buttonpause(View view) {
    }

    public void enter(View view) {
        Intent intent=new Intent(this,showques.class);
        startActivity(intent);
    }
}